export default {
  obj: {}, // 解析歌词后的对象
  obj2: {}, // 备份obj

  // 字符串转换成秒
  parse2 (stri) {
    let arr = stri.split(':');
    let num = 0;
    num = parseInt(arr[0]) * 60 + parseFloat(arr[1]);
    if(isNaN(num)){
      num = 0;
    }
    return num;
  },
  
  // 解析歌词
  parse (str) {
    let arr1 = [], arr2 = [];
    this.obj = {
      time: [],
      content: []
    };
    this.obj2 = {
      time: [],
      content: []
    };
    arr1 = str.split('[');
    arr1.forEach((value, index) => {
      if (index > 0) {
        arr2 = arr2.concat(value.split(']'));
      }
    });
    arr2.forEach((value, index) => {
      if (index % 2 === 0) {
        this.obj.time.push(this.parse2(value));
        this.obj2.time.push(this.parse2(value));
      } else {
        this.obj.content.push(value);
        this.obj2.content.push(value);
      }
    });
    return this.obj;
  }

};